ArabizationWorldMapQuest = ArabizationQuest:New("ArabizationWorldMapQuestScroll")

function ArabizationWorldMapQuest:OnInitialize()
    self:Initialize()

    self.selected = 0
    self.WorldMapQuestScrollFrameHeight = WorldMapQuestScrollFrame:GetHeight()

    ArabizationWorldMapQuestShowArabicText:SetText("Show Arabic")
    ArabizationWorldMapQuestShowArabic:SetPoint("BOTTOMRIGHT", WorldMapTrackQuest, "BOTTOMRIGHT", WorldMapTrackQuestText:GetWidth() + 45, 0)
    self:SetChecked(Arabization.db.profile.quest.worldmap)

	hooksecurefunc("WorldMapFrame_SelectQuestFrame", function(questFrame)
        self.selected = questFrame.questId
        ArabizationWorldMapQuest:QuestInfo(questFrame.questId)
    end)
end

function ArabizationWorldMapQuest:OnEnable()
    Arabization:DebugLog("ArabizationWorldMapQuest: OnEnable.");
end

function ArabizationWorldMapQuest:OnDisable()
    Arabization:DebugLog("ArabizationWorldMapQuest: OnDisable.");
end

function ArabizationWorldMapQuest:ResizeWorldMapQuestScrollFrame()
    if ArabizationWorldMapQuestShowArabic:GetChecked() then
        local h = self.WorldMapQuestScrollFrameHeight - WorldMapQuestDetailScrollFrame:GetHeight() - 8
        WorldMapQuestScrollFrame:SetHeight(h)
    else
        WorldMapQuestScrollFrame:SetHeight(self.WorldMapQuestScrollFrameHeight)
    end
end

function ArabizationWorldMapQuest:QuestInfo(questID)
    if not ArabizationWorldMapQuestShowArabic:GetChecked() then
        return
    end

    self:ShowDefault(questID)
end

function ArabizationWorldMapQuest:OnClickShowArabic()
    self:SetChecked(ArabizationWorldMapQuestShowArabic:GetChecked())
    if ArabizationWorldMapQuestShowArabic:GetChecked() then
        self:QuestInfo(self.selected)
    end
end

function ArabizationWorldMapQuest:SetChecked(check)
    ArabizationWorldMapQuestShowArabic:SetChecked(check)
    if not ArabizationWorldMapQuestShowArabic:GetChecked() then
        self.Frame:Hide()
    end
    self:ResizeWorldMapQuestScrollFrame()
end
